# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: noonov <noonov@gmail.com>

pkgname=skktools
pkgver=1.3.4
pkgrel=4
pkgdesc="Dictionary maintenance tools for the SKK Japanese input method"
arch=('loong64' 'x86_64')
url="http://openlab.ring.gr.jp/skk/"
license=('GPL2')
depends=('gdbm' 'glib2')
optdepends=('ruby' 'python: for skk2cdb.py' 'perl')
source=(http://openlab.ring.gr.jp/skk/tools/${pkgname}-${pkgver}.tar.gz
        skktools-skk2cdb-python3.patch::https://github.com/skk-dev/skktools/commit/dfde96678a4a9f086c50e8130ca61e68af428663.patch)
sha512sums=('8749dfc4f18474db860d8b7cd85fadfc00327b199addb31a339aa78dd66cb98032429664bdad4b47176b5b64b156b7264bc35a284861f6b9ec8cc9979d4d5ce1'
            'f45c77da33a9135ca8fec81bb7fb2df667b9fcbbd3e7ebc25dcfee4cdfe24b88cb8161af8742ee06ba697819caaae4c45277fd13de3ccf70e44efa7dc99bf8d5')

prepare() {
  mv skktools-skktools-1_3_4 $pkgname-$pkgver
  cd $pkgname-$pkgver
  patch -p1 -i ../skktools-skk2cdb-python3.patch
}

build() {
  cd $pkgname-$pkgver

  ./configure --prefix=/usr --with-gdbm
  make
}

package() {
  cd $pkgname-$pkgver

  make DESTDIR="$pkgdir" install

  install -d "$pkgdir"/usr/share/skktools
  cp -a -t "$pkgdir"/usr/share/skktools \
    convert2skk dbm filters \
    saihenkan.rb skk2cdb.py skkdic-diff.scm unannotation.awk

  install -D -m644 skk-xml.el "$pkgdir"/usr/share/emacs/site-lisp/skk-xml.el
}
